package com.twp.auth.domain.authority;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.*;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

@EqualsAndHashCode(
        exclude = {
                "menuList"
        }
)
@ToString(
        exclude = {
                "menuList"
        }
)
@AllArgsConstructor
@NoArgsConstructor
@Data
@Entity
@Table(
        name = "twp_request_url",
        uniqueConstraints = @UniqueConstraint(columnNames = {"code"})
)
public class RequestUrl implements Serializable {
    /**
     * 编号
     */
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Integer id;

    @Column(name = "code",length = 100)
    private String code;

    /**
     * url
     */
    @Column(name = "url")
    private String url;

    /**
     * 类名称
     */
    @Column(name = "className", length = 1000)
    private String className;

    /**
     * url名称
     */
    @Column(name = "name")
    private String name;

    /**
     * 更新时间
     */
    @Column(name = "updateTime")
    private Date updateTime;

    /**
     * 修改人
     */
    @Column(name = "updateUser")
    private String updateUser;

    @Column(name = "method")
    private String method;

//    @OneToMany(targetEntity = MenuUrl.class,fetch = FetchType.LAZY)
//    @JoinColumn(name = "urlCode", referencedColumnName = "code")
//    private Set<MenuUrl> menuUrlSet;
    @JsonIgnore
    @ManyToMany(mappedBy = "requestUrlList",fetch = FetchType.LAZY)
    private List<Menu> menuList;


    @Transient
    private Set<Role> roleList = new HashSet<>();

}
